import 'package:flutter/cupertino.dart' hide CupertinoNavigationBar;
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'cupertino_navbar.dart';


// ignore: must_be_immutable
class CustomCupertinoScaffold extends StatelessWidget {
    Widget body;
    String titleText;
    String? previousPageTitle;
    Color? backgroundColor;
    Color? navBackgroundColor;
    Border? border;
    Widget? leading;
    Widget? trailing;
    Widget? middle;
    bool resizeToAvoidBottomInset;
    CustomCupertinoScaffold({
        Key? key,
        required this.body,
        this.titleText="",
        this.previousPageTitle,
        this.backgroundColor,
        this.navBackgroundColor,
        this.border,
        this.leading,
        this.trailing,
        this.middle,
        this.resizeToAvoidBottomInset=true,
    }) : super(key: key);

    @override
    Widget build(BuildContext context) {
        Color navTextColor=Colors.black;
        if(navBackgroundColor!=null&&navBackgroundColor!=Colors.white){
            navTextColor=Colors.white;
        }
        return CupertinoTheme(
            data: CupertinoThemeData(
                textTheme:CupertinoTextThemeData(
                    primaryColor:navTextColor,
                )
            ),
            child: CupertinoPageScaffold(
                navigationBar: CupertinoNavigationBar(
                    leading:leading,
                    previousPageTitle: previousPageTitle??"返回",
                    previousPageTitleStyle:TextStyle(fontSize: 15.sp),
                    middle: middle??Text(titleText,style: TextStyle(fontSize: 16.sp,color: navTextColor,fontWeight:FontWeight.normal)),
                    backgroundColor: navBackgroundColor??Colors.white,
                    border: border??const Border.fromBorderSide(BorderSide.none),
                    trailing: trailing,
                ),
                backgroundColor:backgroundColor??Colors.white,
                child:SizedBox(
					width: double.infinity,
					child: body,
				),
                resizeToAvoidBottomInset:resizeToAvoidBottomInset
            ),
        );
    }
}
